<template>
	<view class="share-content">
		<view class='head'>
			<span :class="noIndex==index? '.active':''" @click='handleNav(index)' v-for='(item,index) in navList' :key='index'>
				{{ item }}
			</span>
		</view>
		<canvas canvas-id='myCanvas' style='width: 92%;height: 750rpx;margin-left: 4%;margin-top: 100rpx'>
			<view class="content1">
				<view class="share-view">
					<image class='img' src="http://www.xaddcj.com/skin/images/logo.png"></image>
					<p>
						<span>大地智慧点餐</span>
						<image class='code' src="https://qr.api.cli.im/newqr/create?data=http%3A%2F%2Fqr61.cn%2FoCi1UM%2FqRXbslQ&level=H&transparent=0&bgcolor=%23FFFFFF&forecolor=%2F%2Fstatic.clewm.net%2Fcli%2Fimages%2Fbeautify%2Fnew%2Fforecolor%2F17.png&blockpixel=12&marginblock=2&logourl=https%3A%2F%2Fncstatic.clewm.net%2Frsrc%2F2021%2F0605%2F11%2Fe429f0bebaeae4501cf2831b0ee3a2b7.png&size=400&logoshape=ellipse&embed_text_fontfamily=simhei.ttc&eye_use_fore=1&background=images%2Fbackground%2Fbg5.png&wper=0.7&hper=0.7&tper=0.15&lper=0.15&qrcode_eyes=&outcolor=&incolor=&body_type=0&qr_rotate=0&text=&fontfamily=msyh.ttf&fontsize=30&fontcolor=&logo_pos=0&kid=bizcliim&time=1622862772&key=9cf01dd8dd6b5ab282e11c51356af0c7"></image>
					</p>
				</view>
			</view>
		</canvas>
		<p class='btn'>
			<button @click="ctrlImg">保存图片</button>
			<button open-type="share">分享给好友</button>
		</p>
	</view>
</template>

<script>
export default{
	data(){
		return{
			navList: ['进行中的活动','已结束的活动'],
			noIndex: 0
		}
	},
	methods:{
		handleNav(index){
			this.noIndex = index
		},
		ctrlImg(){
			uni.authorize({
				scope: 'scope.writePhotosAlbum',
				success() {
					uni.downloadFile({
						url: 'https://qr.api.cli.im/newqr/create?data=http%3A%2F%2Fqr61.cn%2FoCi1UM%2FqRXbslQ&level=H&transparent=0&bgcolor=%23FFFFFF&forecolor=%2F%2Fstatic.clewm.net%2Fcli%2Fimages%2Fbeautify%2Fnew%2Fforecolor%2F17.png&blockpixel=12&marginblock=2&logourl=https%3A%2F%2Fncstatic.clewm.net%2Frsrc%2F2021%2F0605%2F11%2Fe429f0bebaeae4501cf2831b0ee3a2b7.png&size=400&logoshape=ellipse&embed_text_fontfamily=simhei.ttc&eye_use_fore=1&background=images%2Fbackground%2Fbg5.png&wper=0.7&hper=0.7&tper=0.15&lper=0.15&qrcode_eyes=&outcolor=&incolor=&body_type=0&qr_rotate=0&text=&fontfamily=msyh.ttf&fontsize=30&fontcolor=&logo_pos=0&kid=bizcliim&time=1622862772&key=9cf01dd8dd6b5ab282e11c51356af0c7',
						success(res){
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success() {
									uni.showToast({
										title: "保存成功"
									})
								},
								fail() {
									uni.showToast({
										title: "保存失败",
										icon: "none"
									});
								}
							})
						}
					})
				}
			})
		}
	}
}
</script>

<style lang='scss'>
	.active{
		color: #FF6600;
		border-bottom: 5rpx solid #FF6600;
	}
	.share-content{
		width: 100%;
		height: 100vh;
		overflow: auto;
		background-color: rgba(176,196,222,.1);
	}
	.head{
		width: 100%;
		height: 80rpx;
		border-bottom: 1rpx solid rgba(176,196,222,.1);
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		span{
			width: 40%;
			height: 80rpx;
			line-height: 80rpx;
			box-sizing: border-box;
			text-align: center;
			font-size: 30rpx;
		}
	}
	.content1{
		width: 95%;
		margin-left: 2.5%;
		margin-top: 30rpx;
		.share-view{
			width: 100%;
			height: 700rpx;
			background-color: white;
			border-radius: 20rpx;
			.img{
				width: 80%;
				margin-left: 10%;
			}
			p{
				width: 92%;
				height: 200rpx;
				margin-left: 4%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				.code{
					width: 150rpx;
					height: 150rpx;
				}
			}
		}
	}
	.btn{
		width: 92%;
		margin-left: 4%;
		height: 150rpx;
		display: flex;
		align-items: center;
		justify-content: space-evenly;
		button{
			width: 43%;
			height: 80rpx;
			line-height: 80rpx;
			font-size: 28rpx
		}
		button:first-child{
			background-color: rgba(0,0,0,0);
		}
		button:last-child{
			background-color: #FF6600;
			color: white;
		}
	}
</style>
